#
class myUser:
    i = 123
    def myprint(self):
        return "hello "

# 实例化类
mu = myUser()
print(mu.i)
print(mu.myprint())

# 构造方法及公共属性
class Add:
    def __init__(self,num1,num2):
        self.r = num1
        self.x = num2

    def addNum(self):
        num = self.x + self.r
        return num

add = Add(1, 2)
print(add.r,add.x)
print(add.addNum())

# 私有属性
class person:
    # 基本属性
    name = " "
    # 私有属性
    __hight = 0

    def __init__(self,n,m):
        self.name = n
        self.__hight = m

    def print(self):
        print("%s 说：我 %f 米" %(self.name, self.__hight))

p = person("张三",2)
p.print()

print(p.name)
#私有属性，不可访问
#print(p.__hight)

# 类的继承
class student(person):
    grade = " "
    def __init__(self, n , m, g):
        person.__init__(self,n,m)
        self.grade = g

    def sPrint(self):
        print("%s 说：我考了%d 分" %(self.name,self.grade))
    # 方法重写
    def print(self):
        print("%s 病了" %(self.name))
s = student("里斯",1.57,100)
s.print()
s.sPrint()